<?php
declare (strict_types = 1);

namespace app\command\backend\system;

use app\service\logic\backend\system\AdminService;
use Carbon\Carbon;
use think\console\Input;
use think\console\Output;
use think\console\Command;

/**
 * 员工/部门初始化 执行一次
 *
 * Class RoleInit
 * @package app\command\backend\system
 */
class AdminInit extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('admin department init')
            ->setDescription('the admin department init command');
    }

    protected function execute(Input $input, Output $output)
    {
        $output->writeln('超管初始化开始');

        // 固定数据创建
        $result = invoke(AdminService::class)->initData();
        $output->writeln('生成数据条数: ' . $result->count());

        // 指令输出
        $output->writeln('超管初始化结束-' . Carbon::now()->format('Y-m-d H:i:s'));
    }
}
